import http from './index.js'
import qsString from 'querystring'

export function menulist() {
    return http.get('/menulist?istree=true')
}

export function menuadd(data) {
    return http.post('/menuadd', qsString.stringify(data))
}

export function menudelete(data) {
    return http.post('/menudelete', qsString.stringify(data))
}

export function menuinfo(params) {
    return http.get('/menuinfo', {
        params
    })
}

export function menuedit(data) {
    return http.post('/menuedit', qsString.stringify(data))
}
//角色列表
export function rolelist() {
    return http.get('/rolelist')
}
// 角色添加
export function roleadd(data) {
    return http.post('/roleadd', qsString.stringify(data))
}
// 角色删除
export function roledelete(data) {
    return http.post('/roledelete', qsString.stringify(data))
}
//角色获取（一条）
export function roleInfo(params) {
    return http.get('/roleInfo', {
        params
    })
}
// 角色修改
export function roleedit(data) {
    return http.post('/roleedit', qsString.stringify(data))
}


//管理员列表
export function userlist(params) {
    return http.get('/userlist', {
        params
    })
}
// 管理员添加
export function useradd(data) {
    return http.post('/useradd', qsString.stringify(data))
}
// 管理员删除
export function userdelete(data) {
    return http.post('/userdelete', qsString.stringify(data))
}
//管理员获取（一条）
export function userinfo(params) {
    return http.get('/userinfo', {
        params
    })
}
// 管理员修改
export function useredit(data) {
    return http.post('/useredit', qsString.stringify(data))
}

//管理员总条数
export function getCount() {
    return http.get("/usercount");
}

//管理员登录
export function userLogin(data) {
    return http.post('/userlogin', qsString.stringify(data))
}

// =============商品分类管理=============
//商品分类添加
export function cateadd(data) {
    let file = new FormData();
    for (let i in data) {
        //append 添加
        file.append(i, data[i]);
    }
    return http.post('/cateadd', file)
}

//商品分类列表
export function catelist(params) {
    return http.get('/catelist', {
        params: {
            istree: true
        }
    })
}

//商品分类获取（一条)
export function cateinfo(params) {
    return http.get('/cateinfo', {
        params
    })
}

//商品分类修改
export function cateedit(data) {
    let file = new FormData();
    for (let i in data) {
        //append 添加
        file.append(i, data[i]);
    }
    return http.post('/cateedit', file)
}

//商品分类删除
export function catedelete(data) {
    return http.post('/catedelete', qsString.stringify(data))
}

// =============商品规格管理=============
//商品规格添加
export function specsadd(data) {
    return http.post('/specsadd', data)
}

//商品规格列表
export function specslist(params) {
    return http.get('/specslist', {
        params: {
            istree: true
        }
    })
}

//商品规格总数
export function specscount() {
    return http.get('/specscount')
}

//商品规格获取（一条)
export function specsinfo(params) {
    return http.get('/specsinfo', {
        params
    })
}

//商品规格修改
export function specsedit(data) {
    return http.post('/specsedit', data)
}

//商品规格删除
export function specsdelete(data) {
    return http.post('/specsdelete', qsString.stringify(data))
}

// =============商品管理接口=============
//商品添加
export function goodsadd(data) {
    let file = new FormData();
    for (let i in data) {
        //append 添加
        file.append(i, data[i]);
    }
    return http.post('/goodsadd', file)
}

//商品列表
export function goodslist(params) {
    return http.get('/goodslist', {
        params
    }
    )
}

//商品总数
export function goodscount(){
    return http.get('/goodscount')
}

//商品获取（一条)
export function goodsinfo(params) {
    return http.get('/goodsinfo', {
        params
    })
}

//商品修改
export function goodsedit(data) {
    let file = new FormData();
    for (let i in data) {
        //append 添加
        file.append(i, data[i]);
    }
    return http.post('/goodsedit', file)
}

//商品分类删除
export function goodsdelete(data) {
    return http.post('/goodsdelete', qsString.stringify(data))
}

//==========会员接口===========
export function memberlist() {
    return http.get('/memberlist')
}

export function memberinfo(params) {
    return http.get('/memberinfo', {
        params
    })
}

export function memberedit(data) {
    return http.post('/memberedit', data)
}




//==========秒杀接口===========

export function seckadd(data) {
    return http.post('/seckadd', data)
}

export function secklist(params) {
    return http.get('/secklist', {
        params
    })
}

export function seckdelete(data) {
    return http.post('/seckdelete', data)
}

export function seckinfo(data) {
    return http.get('/seckinfo', data)
}

export function seckedit(data) {
    return http.post('/seckedit', data)
}




// //==========轮播图接口===========

export function banneradd(data) {
    let file = new FormData();
    for (let i in data) {
        //append 添加
        file.append(i, data[i]);
    }
    return http.post('/banneradd', file)
}

export function bannerlist(params) {
    return http.get('/bannerlist', {
        params
    })
}

export function bannerdelete(data) {
    return http.post('/bannerdelete', data)
}

export function bannerinfo(data) {
    return http.get('/bannerinfo', data)
}

export function banneredit(data) {
    let file = new FormData();
    for (let i in data) {
        //append 添加
        file.append(i, data[i]);
    }
    return http.post('/banneredit', file)
}